home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / misc / mf-db.zip / VBSAMPLE\MF.BAS < prev    next >
BASIC Source File  |  1993-10-01  |  5KB  |  131 lines

  1. Option Explicit
  2. '*************  MF DLL calls ***************
  3.  
  4. ' Use this file with any program you create in VB
  5. ' It contains all the declarations needed for accessing
  6. ' the MF database.
  7.  
  8.     ' *** ADMIN ***
  9. Declare Function mfInit% Lib "mf.dll" (extensionDLLs As Any)
  10. Declare Function mfDeInit% Lib "mf.dll" (ByVal task%)
  11. Declare Function mfOpen% Lib "mf.dll" (ByVal FileName$, ByVal task%)
  12. Declare Function mfClose% Lib "mf.dll" (ByVal task%, ByVal dbHndl%)
  13. Declare Function mfCreateDB% Lib "mf.dll" (ByVal FileName$, ByVal RecSize%, ByVal NumIndexs%, rSizeArray As Any, typeArray As Any)
  14.  
  15.     ' *** GENERAL ***
  16. Declare Function mfInfoDB% Lib "mf.dll" (RecSize%, NumIndexs%, NumRecs&, LiveRecs&, ByVal task%, ByVal dbHndl%)
  17. Declare Function mfInfoIndex% Lib "mf.dll" (ByVal task%, ByVal dbHndl%, ByVal indexNumber%)
  18. Declare Function mfIsDeleted% Lib "mf.dll" (ByVal RecordNum&, ByVal task%, ByVal dbHndl%)
  19. Declare Function mfReIndex% Lib "mf.dll" (ByVal anHwnd%, ByVal task%, ByVal dbHndl%)
  20. Declare Function mfLock% Lib "mf.dll" (ByVal RecordNum&, ByVal task%, ByVal dbHndl%)
  21. Declare Function mfUnLock% Lib "mf.dll" (ByVal RecordNum&, ByVal task%, ByVal dbHndl%)
  22.  
  23.  
  24.  
  25.  
  26.     ' *** DATA I/O ***
  27. Declare Function mfRead% Lib "mf.dll" (ByVal RecordNum&, record As Any, ByVal task%, ByVal dbHndl%, ByVal opt%)
  28. Declare Function mfWrite% Lib "mf.dll" (ByVal RecordNum&, record As Any, ByVal task%, ByVal dbHndl%, ByVal opt%)
  29. Declare Function mfDelete% Lib "mf.dll" (ByVal RecordNum&, ByVal task%, ByVal dbHndl%)
  30. Declare Function mfAppendData& Lib "mf.dll" (record As Any, ByVal task%, ByVal dbHndl%)
  31.  
  32.     ' ***  Movement  ***
  33. Declare Function mfTop& Lib "mf.dll" (ByVal task%, ByVal dbHndl%, ByVal indexNumber%)
  34. Declare Function mfBottom& Lib "mf.dll" (ByVal task%, ByVal dbHndl%, ByVal indexNumber%)
  35. Declare Function mfSkip& Lib "mf.dll" (ByVal FromRecord&, ByVal HowFarToSkip&, ByVal task%, ByVal dbHndl%, ByVal indexNumber%)
  36.     ' Since VB doesn't support passing 'void' pointers -- we have to trick it to do the job
  37.     ' SeekS is for STRINGS
  38.     ' SeekO is for anything else...
  39. Declare Function mfSeekS& Lib "mf.dll" Alias "mfSeek" (ByVal skStr$, retcode%, ByVal task%, ByVal dbHndl%, ByVal xNum%)
  40. Declare Function mfSeekO& Lib "mf.dll" Alias "mfSeek" (skStr As Any, retcode%, ByVal task%, ByVal dbHndl%, ByVal xNum%)
  41.  
  42.  
  43.     ' Severe-Performance functions
  44. Declare Function mfReadListS& Lib "mf.dll" Alias "mfReadList" (ByVal record As Long, ByVal skStr$, ByVal FuzzyLength%, hitList As Any, ByVal maxHits&, ByVal task%, ByVal dbHndl%, ByVal xNum%)
  45. Declare Function mfReadListO& Lib "mf.dll" Alias "mfReadList" (ByVal record As Long, skStr As Any, ByVal FuzzyLength%, hitList As Any, ByVal maxHits&, ByVal task%, ByVal dbHndl%, ByVal xNum%)
  46. Declare Function mfReadListNull& Lib "mf.dll" Alias "mfReadList" (ByVal record As Long, ByVal skStr As Long, ByVal FuzzyLength%, hitList As Any, ByVal maxHits&, ByVal task%, ByVal dbHndl%, ByVal xNum%)
  47.  
  48.  
  49.  
  50. ' Constants:
  51. ' READ and WRITE options
  52. Global Const MFRW_ALL = -1
  53. Global Const MFRW_DATA = -2
  54. Global Const MFRW_KEY = -3
  55.  
  56.     ' Seek Top/Bottom
  57.     ' Return codes when there's no higher/lower key
  58.     ' or no data at all...
  59. Global Const MFSEEK_BOF = -1
  60. Global Const MFSEEK_EOF = -2
  61. Global Const MFSEEK_NODATA = -3
  62.  
  63.     ' parameter set in iCode for an mfSeek
  64. Global Const MFSEEK_EXACT_MATCH = 1
  65. Global Const MFSEEK_PARTIAL_MATCH = 2
  66.  
  67.     ' SP constants
  68. Global Const MF_SP_COUNT = -1
  69.  
  70.     ' index type information
  71. Global Const MFCOMP_CHAR = 1
  72. Global Const MFCOMP_INT = 2
  73. Global Const MFCOMP_LONG = 3
  74. Global Const MFCOMP_CHARIC = 4  ' Case insensitive strings
  75. Global Const MFCOMP_UDK = 100   ' Or greater...
  76.  
  77.     ' used for an array on index sizes on createDB
  78. Type tIntArray
  79.     i As Integer
  80. End Type
  81.  
  82.     ' Used for getting a hit-list in the severe-performance functions
  83. Type tLongArray
  84.     l As Long
  85. End Type
  86.  
  87. ' Required on mfInit when using extensions to MF
  88. Type tExtDLL
  89.     type As Integer
  90.     DLLName As String * 128
  91. End Type
  92.  
  93.     ' Need 1 task handle per application instance
  94. Global TaskHndl As Integer ' Task handle # for this instance
  95.  
  96. Sub mfBeginRun ()
  97.     ReDim extDLLs(0 To 1) As tExtDLL
  98.     
  99.     extDLLs(0).type = MFCOMP_UDK    ' tells mf to use this dll for UDK's
  100.     extDLLs(0).DLLName = "mfUDK.dll"
  101.     extDLLs(1).type = -1    ' tells MF there are NO more extensions to load
  102.  
  103.  
  104.     ' Add this line as the first line in your application
  105.     ' (or, at least before you use the dbms)
  106.     ' The TaskHndl is your unique handle to the database
  107.     ' If the hndl is -1, then 10 apps are already accessing the
  108.     ' database -- close some!
  109.     TaskHndl = mfInit(extDLLs(0))
  110.     If TaskHndl < 0 Then
  111.         MsgBox "No database handles available -- please close some active windows"
  112.         End
  113.     End If
  114. End Sub
  115.  
  116. ' Call when you are completely done with the database
  117. ' for the entire program...
  118. Sub mfEndRun ()
  119.     junk = mfDeInit(TaskHndl)
  120. End Sub
  121.  
  122. ' Pad a string with 'char'
  123. Function Pad$ (num%, char$)
  124.     Dim n%, r$
  125.     For n = 1 To num
  126.         r = r + char
  127.     Next n
  128.     Pad = r
  129. End Function
  130.  
  131.